Merge branch 'master' of github.com:thelia/thelia
This commit is contained in:
@@ -40,6 +40,10 @@ use Thelia\Core\Event\ProductAddContentEvent;
|
||||
use Thelia\Core\Event\ProductDeleteContentEvent;
|
||||
use Thelia\Model\ProductAssociatedContent;
|
||||
use Thelia\Model\ProductAssociatedContentQuery;
|
||||
use Thelia\Model\ProductCategory;
|
||||
use Thelia\Model\TaxRule;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
use Thelia\Model\TaxQuery;
|
||||
|
||||
class Product extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -55,13 +59,16 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setRef($event->getRef())
|
||||
->setTitle($event->getTitle())
|
||||
->setParent($event->getParent())
|
||||
->setLocale($event->getLocale())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
->save()
|
||||
;
|
||||
// Set the default tax rule to this product
|
||||
->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true))
|
||||
|
||||
->create($event->getDefaultCategory())
|
||||
;
|
||||
|
||||
$event->setProduct($product);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<loop class="Thelia\Core\Template\Loop\Message" name="message"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Delivery" name="delivery"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Template" name="template"/> <!-- This is product templates ;-) -->
|
||||
<loop class="Thelia\Core\Template\Loop\TaxRule" name="tax-rule"/>
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
|
||||
@@ -83,9 +83,10 @@ class ProductController extends AbstractCrudController
|
||||
$createEvent = new ProductCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setRef($formData['ref'])
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
->setParent($formData['parent'])
|
||||
->setLocale($formData['locale'])
|
||||
->setDefaultCategory($formData['default_category'])
|
||||
->setVisible($formData['visible'])
|
||||
;
|
||||
|
||||
@@ -134,15 +135,15 @@ class ProductController extends AbstractCrudController
|
||||
{
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'parent' => $object->getParent()
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'default_category' => $object->getDefaultCategoryId()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
@@ -174,12 +175,26 @@ class ProductController extends AbstractCrudController
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'product_id' => $this->getRequest()->get('product_id', 0),
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'category_id' => $this->getCategoryId(),
|
||||
'product_id' => $this->getRequest()->get('product_id', 0),
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCategoryId() {
|
||||
// Trouver le category_id, soit depuis la reques, souit depuis le produit courant
|
||||
$category_id = $this->getRequest()->get('category_id', null);
|
||||
|
||||
if ($category_id == null) {
|
||||
$product = $this->getExistingObject();
|
||||
|
||||
if ($product !== null) $category_id = $product->getDefaultCategoryId();
|
||||
}
|
||||
|
||||
return $category_id != null ? $category_id : 0;
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
$this->getListOrderFromSession('product', 'product_order', 'manual');
|
||||
@@ -187,18 +202,15 @@ class ProductController extends AbstractCrudController
|
||||
return $this->render('categories',
|
||||
array(
|
||||
'product_order' => $currentOrder,
|
||||
'product_id' => $this->getRequest()->get('product_id', 0)
|
||||
'category_id' => $this->getCategoryId()
|
||||
));
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
// Redirect to the product default category list
|
||||
$product = $this->getExistingObject();
|
||||
|
||||
$this->redirectToRoute(
|
||||
'admin.products.default',
|
||||
array('category_id' => $product != null ? $product->getDefaultCategory() : 0)
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -238,7 +250,7 @@ class ProductController extends AbstractCrudController
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.products.default',
|
||||
array('category_id' => $deleteEvent->getProduct()->getDefaultCategory())
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -249,24 +261,18 @@ class ProductController extends AbstractCrudController
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $product->getDefaultCategory())
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdatePositionAction($event)
|
||||
protected function performAdditionalUpdatePositionAction($positionEvent)
|
||||
{
|
||||
$product = ProductQuery::create()->findPk($event->getObjectId());
|
||||
|
||||
if ($product != null) {
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $product->getDefaultCategory())
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
public function getAvailableRelatedContentAction($productId, $folderId)
|
||||
|
||||
@@ -25,11 +25,23 @@ namespace Thelia\Core\Event;
|
||||
|
||||
class ProductCreateEvent extends ProductEvent
|
||||
{
|
||||
protected $ref;
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
protected $default_category;
|
||||
protected $visible;
|
||||
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
@@ -38,19 +50,6 @@ class ProductCreateEvent extends ProductEvent
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -62,7 +61,17 @@ class ProductCreateEvent extends ProductEvent
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDefaultCategory()
|
||||
{
|
||||
return $this->default_category;
|
||||
}
|
||||
|
||||
public function setDefaultCategory($default_category)
|
||||
{
|
||||
$this->default_category = $default_category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -74,7 +83,6 @@ class ProductCreateEvent extends ProductEvent
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class Image extends BaseI18nLoop
|
||||
$source_id = $this->getSourceId();
|
||||
$id = $this->getId();
|
||||
|
||||
//echo "source = ".$this->getSource()."source_id=$source_id, id=$id<br />";
|
||||
//echo "source = ".$this->getSourceId()."source_id=$source_id, id=$id<br />";
|
||||
|
||||
if (is_null($source_id) && is_null($id)) {
|
||||
throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified");
|
||||
@@ -214,6 +214,7 @@ class Image extends BaseI18nLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
|
||||
// Select the proper query to use, and get the object type
|
||||
$object_type = $object_id = null;
|
||||
|
||||
@@ -262,13 +263,14 @@ class Image extends BaseI18nLoop
|
||||
|
||||
}
|
||||
|
||||
//echo "sql=".$search->toString();
|
||||
// echo "sql=".$search->toString();
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
// Create image processing event
|
||||
$event = new ImageEvent($this->request);
|
||||
|
||||
@@ -315,7 +317,8 @@ class Image extends BaseI18nLoop
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
} catch (\Exception $ex) {
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Ignore the result and log an error
|
||||
Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args);
|
||||
}
|
||||
|
||||
@@ -598,31 +598,59 @@ class Product extends BaseI18nLoop
|
||||
$loopResult = new LoopResult($products);
|
||||
|
||||
foreach ($products as $product) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $product->getRealLowestPrice();
|
||||
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
|
||||
// Find previous and next product, in the default category.
|
||||
$default_category_id = $product->getDefaultCategoryId();
|
||||
|
||||
$loopResultRow->set("ID", $product->getId())
|
||||
->set("REF",$product->getRef())
|
||||
->set("IS_TRANSLATED",$product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("TITLE",$product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL", $product->getUrl($locale))
|
||||
->set("BEST_PRICE", $price)
|
||||
->set("BEST_PRICE_TAX", $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE", $taxedPrice)
|
||||
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION", $product->getPosition())
|
||||
$previous = ProductQuery::create()
|
||||
->joinProductCategory()
|
||||
->where('ProductCategory.category_id = ?', $default_category_id)
|
||||
->filterByPosition($product->getPosition(), Criteria::LESS_THAN)
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$next = ProductQuery::create()
|
||||
->joinProductCategory()
|
||||
->where('ProductCategory.category_id = ?', $default_category_id)
|
||||
->filterByPosition($product->getPosition(), Criteria::GREATER_THAN)
|
||||
->orderByPosition(Criteria::ASC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $product->getId())
|
||||
->set("REF" , $product->getRef())
|
||||
->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL" , $product->getUrl($locale))
|
||||
->set("BEST_PRICE" , $price)
|
||||
->set("BEST_PRICE_TAX" , $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE" , $taxedPrice)
|
||||
->set("IS_PROMO" , $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW" , $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION" , $product->getPosition())
|
||||
->set("VISIBLE" , $product->getVisible() ? "1" : "0")
|
||||
->set("HAS_PREVIOUS" , $previous != null ? 1 : 0)
|
||||
->set("HAS_NEXT" , $next != null ? 1 : 0)
|
||||
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
->set("DEFAULT_CATEGORY" , $default_category_id)
|
||||
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
135
core/lib/Thelia/Core/Template/Loop/TaxRule.php
Normal file
135
core/lib/Thelia/Core/Template/Loop/TaxRule.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* TaxRule loop
|
||||
*
|
||||
*
|
||||
* Class TaxRule
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class TaxRule extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse'))
|
||||
),
|
||||
'alpha'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = TaxRuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (null !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case "id_reverse":
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$tax_rules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($tax_rules);
|
||||
|
||||
foreach ($tax_rules as $tax_rule) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $tax_rule, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $tax_rule->getId())
|
||||
->set("IS_TRANSLATED" , $tax_rule->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $tax_rule->getVirtualColumn('i18n_TITLE'))
|
||||
->set("DESCRIPTION" , $tax_rule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("IS_DEFAULT" , $tax_rule->getIsDefault() ? '1' : '0')
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -23,16 +23,26 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
|
||||
class ProductCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$ref_constraints = array(new NotBlank());
|
||||
|
||||
if (! $change_mode) {
|
||||
$ref_constraints[] = new Callback(array(
|
||||
"methods" => array(array($this, "checkDuplicateRef"))
|
||||
));
|
||||
}
|
||||
|
||||
$this->formBuilder
|
||||
->add("ref", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"constraints" => $ref_constraints,
|
||||
"label" => "Product reference *",
|
||||
"label_attr" => array(
|
||||
"for" => "ref"
|
||||
@@ -64,6 +74,19 @@ class ProductCreationForm extends BaseForm
|
||||
;
|
||||
}
|
||||
|
||||
public function checkDuplicateRef($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$count = ProductQuery::create()->filterByRef($value)->count();
|
||||
|
||||
if ($count > 0) {
|
||||
$context->addViolation(
|
||||
Translator::getInstance()->trans(
|
||||
"A product with reference %ref already exists. Please choose another reference.",
|
||||
array('%ref' => $value)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_product_creation";
|
||||
|
||||
@@ -67,6 +67,13 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The value for the is_default field.
|
||||
* Note: this column has a database default value of: false
|
||||
* @var boolean
|
||||
*/
|
||||
protected $is_default;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var string
|
||||
@@ -137,11 +144,24 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
*/
|
||||
protected $taxRuleI18nsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* Applies default values to this object.
|
||||
* This method should be called from the object's constructor (or
|
||||
* equivalent initialization method).
|
||||
* @see __construct()
|
||||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->is_default = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes internal state of Thelia\Model\Base\TaxRule object.
|
||||
* @see applyDefaults()
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->applyDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,6 +422,17 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [is_default] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsDefault()
|
||||
{
|
||||
|
||||
return $this->is_default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [created_at] column value.
|
||||
*
|
||||
@@ -463,6 +494,35 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Sets the value of the [is_default] column.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
*
|
||||
* @param boolean|integer|string $v The new value
|
||||
* @return \Thelia\Model\TaxRule The current object (for fluent API support)
|
||||
*/
|
||||
public function setIsDefault($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
if (is_string($v)) {
|
||||
$v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
} else {
|
||||
$v = (boolean) $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->is_default !== $v) {
|
||||
$this->is_default = $v;
|
||||
$this->modifiedColumns[] = TaxRuleTableMap::IS_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setIsDefault()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
@@ -515,6 +575,10 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->is_default !== false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise, everything was equal, so return TRUE
|
||||
return true;
|
||||
} // hasOnlyDefaultValues()
|
||||
@@ -545,13 +609,16 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->is_default = (null !== $col) ? (boolean) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -564,7 +631,7 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 3; // 3 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 4; // 4 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\TaxRule object", 0, $e);
|
||||
@@ -845,6 +912,9 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(TaxRuleTableMap::ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ID';
|
||||
}
|
||||
if ($this->isColumnModified(TaxRuleTableMap::IS_DEFAULT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_DEFAULT';
|
||||
}
|
||||
if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
}
|
||||
@@ -865,6 +935,9 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
case 'ID':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_DEFAULT':
|
||||
$stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
@@ -937,9 +1010,12 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getIsDefault();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -972,8 +1048,9 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
$keys = TaxRuleTableMap::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getCreatedAt(),
|
||||
$keys[2] => $this->getUpdatedAt(),
|
||||
$keys[1] => $this->getIsDefault(),
|
||||
$keys[2] => $this->getCreatedAt(),
|
||||
$keys[3] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1029,9 +1106,12 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setIsDefault($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1059,8 +1139,9 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
$keys = TaxRuleTableMap::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setCreatedAt($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setUpdatedAt($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setIsDefault($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1073,6 +1154,7 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
$criteria = new Criteria(TaxRuleTableMap::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(TaxRuleTableMap::ID)) $criteria->add(TaxRuleTableMap::ID, $this->id);
|
||||
if ($this->isColumnModified(TaxRuleTableMap::IS_DEFAULT)) $criteria->add(TaxRuleTableMap::IS_DEFAULT, $this->is_default);
|
||||
if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) $criteria->add(TaxRuleTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) $criteria->add(TaxRuleTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1138,6 +1220,7 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
|
||||
{
|
||||
$copyObj->setIsDefault($this->getIsDefault());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
|
||||
@@ -1961,10 +2044,12 @@ abstract class TaxRule implements ActiveRecordInterface
|
||||
public function clear()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->is_default = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->clearAllReferences();
|
||||
$this->applyDefaultValues();
|
||||
$this->resetModified();
|
||||
$this->setNew(true);
|
||||
$this->setDeleted(false);
|
||||
|
||||
@@ -23,10 +23,12 @@ use Thelia\Model\Map\TaxRuleTableMap;
|
||||
*
|
||||
*
|
||||
* @method ChildTaxRuleQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildTaxRuleQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column
|
||||
* @method ChildTaxRuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildTaxRuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
* @method ChildTaxRuleQuery groupById() Group by the id column
|
||||
* @method ChildTaxRuleQuery groupByIsDefault() Group by the is_default column
|
||||
* @method ChildTaxRuleQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildTaxRuleQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -50,10 +52,12 @@ use Thelia\Model\Map\TaxRuleTableMap;
|
||||
* @method ChildTaxRule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTaxRule matching the query, or a new ChildTaxRule object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildTaxRule findOneById(int $id) Return the first ChildTaxRule filtered by the id column
|
||||
* @method ChildTaxRule findOneByIsDefault(boolean $is_default) Return the first ChildTaxRule filtered by the is_default column
|
||||
* @method ChildTaxRule findOneByCreatedAt(string $created_at) Return the first ChildTaxRule filtered by the created_at column
|
||||
* @method ChildTaxRule findOneByUpdatedAt(string $updated_at) Return the first ChildTaxRule filtered by the updated_at column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildTaxRule objects filtered by the id column
|
||||
* @method array findByIsDefault(boolean $is_default) Return ChildTaxRule objects filtered by the is_default column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildTaxRule objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildTaxRule objects filtered by the updated_at column
|
||||
*
|
||||
@@ -144,7 +148,7 @@ abstract class TaxRuleQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -274,6 +278,33 @@ abstract class TaxRuleQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(TaxRuleTableMap::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the is_default column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByIsDefault(true); // WHERE is_default = true
|
||||
* $query->filterByIsDefault('yes'); // WHERE is_default = true
|
||||
* </code>
|
||||
*
|
||||
* @param boolean|string $isDefault The value to use as filter.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildTaxRuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByIsDefault($isDefault = null, $comparison = null)
|
||||
{
|
||||
if (is_string($isDefault)) {
|
||||
$is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(TaxRuleTableMap::IS_DEFAULT, $isDefault, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
|
||||
@@ -57,7 +57,7 @@ class TaxRuleTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 3;
|
||||
const NUM_COLUMNS = 4;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,13 +67,18 @@ class TaxRuleTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 3;
|
||||
const NUM_HYDRATE_COLUMNS = 4;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
*/
|
||||
const ID = 'tax_rule.ID';
|
||||
|
||||
/**
|
||||
* the column name for the IS_DEFAULT field
|
||||
*/
|
||||
const IS_DEFAULT = 'tax_rule.IS_DEFAULT';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
@@ -105,12 +110,12 @@ class TaxRuleTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, )
|
||||
self::TYPE_PHPNAME => array('Id', 'IsDefault', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'isDefault', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::IS_DEFAULT, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'is_default', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -120,12 +125,12 @@ class TaxRuleTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'CreatedAt' => 1, 'UpdatedAt' => 2, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'createdAt' => 1, 'updatedAt' => 2, ),
|
||||
self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::CREATED_AT => 1, TaxRuleTableMap::UPDATED_AT => 2, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREATED_AT' => 1, 'UPDATED_AT' => 2, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'created_at' => 1, 'updated_at' => 2, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'IsDefault' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'isDefault' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
|
||||
self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::IS_DEFAULT => 1, TaxRuleTableMap::CREATED_AT => 2, TaxRuleTableMap::UPDATED_AT => 3, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'IS_DEFAULT' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'is_default' => 1, 'created_at' => 2, 'updated_at' => 3, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -145,6 +150,7 @@ class TaxRuleTableMap extends TableMap
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', true, 1, false);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -323,10 +329,12 @@ class TaxRuleTableMap extends TableMap
|
||||
{
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(TaxRuleTableMap::ID);
|
||||
$criteria->addSelectColumn(TaxRuleTableMap::IS_DEFAULT);
|
||||
$criteria->addSelectColumn(TaxRuleTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(TaxRuleTableMap::UPDATED_AT);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.IS_DEFAULT');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\ProductEvent;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\Map\ProductTableMap;
|
||||
|
||||
class Product extends BaseProduct
|
||||
{
|
||||
@@ -41,11 +43,12 @@ class Product extends BaseProduct
|
||||
public function getTaxedPrice(Country $country)
|
||||
{
|
||||
$taxCalculator = new Calculator();
|
||||
return round($taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()), 2);
|
||||
|
||||
return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current default category for this product
|
||||
* @return the current default category ID for this product
|
||||
*/
|
||||
public function getDefaultCategoryId()
|
||||
{
|
||||
@@ -84,6 +87,72 @@ class Product extends BaseProduct
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new product, along with the default category ID
|
||||
*
|
||||
* @param int $defaultCategoryId the default category ID of this product
|
||||
*/
|
||||
public function create($defaultCategoryId) {
|
||||
|
||||
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));
|
||||
|
||||
try {
|
||||
// Create the product
|
||||
$this->save($con);
|
||||
|
||||
// Add the default category
|
||||
$pc = new ProductCategory();
|
||||
|
||||
$pc
|
||||
->setProduct($this)
|
||||
->setCategoryId($defaultCategoryId)
|
||||
->setDefaultCategory(true)
|
||||
->save($con)
|
||||
;
|
||||
|
||||
// Set the position
|
||||
$this->setPosition($this->getNextPosition())->save($con);
|
||||
|
||||
// Create an empty product sale element
|
||||
$sale_elements = new ProductSaleElements();
|
||||
|
||||
$sale_elements
|
||||
->setProduct($this)
|
||||
->setRef($this->getRef())
|
||||
->setPromo(0)
|
||||
->setNewness(0)
|
||||
->setWeight(0)
|
||||
->save($con)
|
||||
;
|
||||
|
||||
// Create an empty product price in the default currency
|
||||
$product_price = new ProductPrice();
|
||||
|
||||
$product_price
|
||||
->setProductSaleElements($sale_elements)
|
||||
->setPromoPrice(0)
|
||||
->setPrice(0)
|
||||
->setCurrency(CurrencyQuery::create()->findOneByByDefault(true))
|
||||
->save($con)
|
||||
;
|
||||
|
||||
// Store all the stuff !
|
||||
$con->commit();
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
|
||||
}
|
||||
catch(\Exception $ex) {
|
||||
|
||||
$con->rollback();
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our default category
|
||||
*/
|
||||
@@ -100,31 +169,7 @@ class Product extends BaseProduct
|
||||
if ($produits != null) $query->filterById($produits, Criteria::IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEPRODUCT, new ProductEvent($this));
|
||||
@@ -157,5 +202,4 @@ class Product extends BaseProduct
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('\Thelia\Core\Template\Element\LoopResult', $methodReturn);
|
||||
}
|
||||
|
||||
public function baseTestSearchById($id)
|
||||
public function baseTestSearchById($id, $other_args = array())
|
||||
{
|
||||
$this->instance->initializeArgs(array_merge(
|
||||
$this->getMandatoryArguments(),
|
||||
@@ -140,7 +140,8 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase
|
||||
"type" => "foo",
|
||||
"name" => "foo",
|
||||
"id" => $id,
|
||||
)
|
||||
),
|
||||
$other_args
|
||||
));
|
||||
|
||||
$dummy = null;
|
||||
|
||||
@@ -58,32 +58,27 @@ class DocumentTest extends BaseLoopTestor
|
||||
{
|
||||
$document = ProductDocumentQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($document->getId());
|
||||
$this->baseTestSearchById($document->getId(), array('source' => 'product'));
|
||||
}
|
||||
|
||||
public function testSearchByFolderId()
|
||||
{
|
||||
$document = FolderDocumentQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($document->getId());
|
||||
$this->baseTestSearchById($document->getId(), array('source' => 'folder'));
|
||||
}
|
||||
|
||||
public function testSearchByContentId()
|
||||
{
|
||||
$document = ContentDocumentQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($document->getId());
|
||||
$this->baseTestSearchById($document->getId(), array('source' => 'content'));
|
||||
}
|
||||
|
||||
public function testSearchByCategoryId()
|
||||
{
|
||||
$document = CategoryDocumentQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($document->getId());
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
{
|
||||
$this->baseTestSearchWithLimit(1);
|
||||
$this->baseTestSearchById($document->getId(), array('source' => 'category'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,32 +58,27 @@ class ImageTest extends BaseLoopTestor
|
||||
{
|
||||
$image = ProductImageQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($image->getId());
|
||||
$this->baseTestSearchById($image->getId(), array('source' => 'product'));
|
||||
}
|
||||
|
||||
public function testSearchByFolderId()
|
||||
{
|
||||
$image = FolderImageQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($image->getId());
|
||||
$this->baseTestSearchById($image->getId(), array('source' => 'folder'));
|
||||
}
|
||||
|
||||
public function testSearchByContentId()
|
||||
{
|
||||
$image = ContentImageQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($image->getId());
|
||||
$this->baseTestSearchById($image->getId(), array('source' => 'content'));
|
||||
}
|
||||
|
||||
public function testSearchByCategoryId()
|
||||
{
|
||||
$image = CategoryImageQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($image->getId());
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
{
|
||||
$this->baseTestSearchWithLimit(1);
|
||||
$this->baseTestSearchById($image->getId(), array('source' => 'category'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ use Thelia\Model\ProductQuery;
|
||||
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
|
||||
|
||||
use Thelia\Core\Template\Loop\Product;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -52,7 +53,7 @@ class ProductTest extends BaseLoopTestor
|
||||
|
||||
public function testSearchById()
|
||||
{
|
||||
$product = ProductQuery::create()->findOne();
|
||||
$product = ProductQuery::create()->orderById(Criteria::ASC)->findOne();
|
||||
|
||||
$this->baseTestSearchById($product->getId());
|
||||
}
|
||||
|
||||
60
core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php
Normal file
60
core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Core\Template\Loop;
|
||||
|
||||
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
|
||||
|
||||
use Thelia\Core\Template\Loop\TaxRule;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class TaxRuleTest extends BaseLoopTestor
|
||||
{
|
||||
public function getTestedClassName()
|
||||
{
|
||||
return 'Thelia\Core\Template\Loop\TaxRule';
|
||||
}
|
||||
|
||||
public function getTestedInstance()
|
||||
{
|
||||
return new TaxRule($this->container);
|
||||
}
|
||||
|
||||
public function getMandatoryArguments()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function testSearchById()
|
||||
{
|
||||
$tr = TaxRuleQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($tr->getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$productQuery = ProductQuery::create()->findOneById(1);
|
||||
$productQuery = ProductQuery::create()->findOne();
|
||||
$countryQuery = CountryQuery::create()->findOneById(64);
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
@@ -1137,9 +1137,9 @@ INSERT INTO `tax_i18n` (`id`, `locale`, `title`)
|
||||
(1, 'fr_FR', 'TVA française à 19.6%'),
|
||||
(1, 'en_UK', 'french 19.6% tax');
|
||||
|
||||
INSERT INTO `tax_rule` (`id`, `created_at`, `updated_at`)
|
||||
INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
(1, NOW(), NOW());
|
||||
(1, 1, NOW(), NOW());
|
||||
|
||||
INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`)
|
||||
VALUES
|
||||
|
||||
@@ -135,6 +135,7 @@ DROP TABLE IF EXISTS `tax_rule`;
|
||||
CREATE TABLE `tax_rule`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`is_default` TINYINT(1) DEFAULT 0 NOT NULL,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,452 +5,534 @@
|
||||
{block name="check-permissions"}admin.categories.view{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="categories">
|
||||
<div class="categories">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{include file="includes/catalog-breadcrumb.html"}
|
||||
{include file="includes/catalog-breadcrumb.html"}
|
||||
|
||||
{module_include location='categories_top'}
|
||||
{module_include location='categories_top'}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="general-block-decorator">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="general-block-decorator">
|
||||
|
||||
<table class="table table-striped table-condensed" id="category_list">
|
||||
<caption>
|
||||
{* display parent category name, and get current cat ID *}
|
||||
{loop name="category_title" type="category" visible="*" id=$category_id}
|
||||
{intl l="Categories in %cat" cat=$TITLE}
|
||||
{$cat_id = $ID}
|
||||
{/loop}
|
||||
{elseloop rel="category_title"}
|
||||
{intl l="Top level categories"}
|
||||
{/elseloop}
|
||||
<table class="table table-striped table-condensed" id="category_list">
|
||||
<caption>
|
||||
{* display parent category name, and get current cat ID *}
|
||||
{loop name="category_title" type="category" visible="*" id=$category_id}
|
||||
{intl l="Categories in %cat" cat=$TITLE}
|
||||
{$cat_id = $ID}
|
||||
{/loop}
|
||||
{elseloop rel="category_title"}
|
||||
{intl l="Top level categories"}
|
||||
{/elseloop}
|
||||
|
||||
{module_include location='category_list_caption'}
|
||||
{module_include location='category_list_caption'}
|
||||
|
||||
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"}
|
||||
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new category'}" href="#category_creation_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
{/loop}
|
||||
</caption>
|
||||
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"}
|
||||
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new category'}" href="#category_creation_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
{/loop}
|
||||
</caption>
|
||||
|
||||
{ifloop rel="category_list"}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='id'
|
||||
reverse_order='id_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id}
|
||||
request_parameter_name='category_order'
|
||||
label="{intl l='ID'}"
|
||||
}
|
||||
</th>
|
||||
{ifloop rel="category_list"}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='id'
|
||||
reverse_order='id_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id}
|
||||
request_parameter_name='category_order'
|
||||
label="{intl l='ID'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th class="object-image"> </th>
|
||||
<th class="object-image"> </th>
|
||||
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='alpha'
|
||||
reverse_order='alpha_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id}
|
||||
request_parameter_name='category_order'
|
||||
label="{intl l='Category title'}"
|
||||
}
|
||||
</th>
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='alpha'
|
||||
reverse_order='alpha_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id}
|
||||
request_parameter_name='category_order'
|
||||
label="{intl l='Category title'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
{module_include location='category_list_header'}
|
||||
{module_include location='category_list_header'}
|
||||
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='visible'
|
||||
reverse_order='visible_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id}
|
||||
request_parameter_name='category_order'
|
||||
label="{intl l='Online'}"
|
||||
}
|
||||
</th>
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='visible'
|
||||
reverse_order='visible_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id}
|
||||
request_parameter_name='category_order'
|
||||
label="{intl l='Online'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='manual'
|
||||
reverse_order='manual_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id}
|
||||
request_parameter_name='category_order'
|
||||
label="{intl l='Position'}"
|
||||
}
|
||||
</th>
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='manual'
|
||||
reverse_order='manual_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id}
|
||||
request_parameter_name='category_order'
|
||||
label="{intl l='Position'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th class="actions">{intl l='Actions'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<th class="actions">{intl l='Actions'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{loop name="category_list" type="category" visible="*" parent=$category_id order=$category_order backend_context="1" lang=$lang_id}
|
||||
<tr>
|
||||
<td>{$ID}</td>
|
||||
<tbody>
|
||||
{loop name="category_list" type="category" visible="*" parent=$category_id order=$category_order backend_context="1" lang=$lang_id}
|
||||
<tr>
|
||||
<td>{$ID}</td>
|
||||
|
||||
<td>
|
||||
{loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
|
||||
<a href="{url path='admin/catalog' category_id=$ID}" title="{intl l='Browse this category'}"><img class="img-thumbnail" src="{$IMAGE_URL}" alt="{$TITLE}" /></a>
|
||||
{/loop}
|
||||
</td>
|
||||
<td>
|
||||
{loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
|
||||
<a href="{url path='admin/catalog' category_id=$ID}" title="{intl l='Browse this category'}"><img class="img-thumbnail" src="{$IMAGE_URL}" alt="{$TITLE}" /></a>
|
||||
{/loop}
|
||||
</td>
|
||||
|
||||
<td class="object-title">
|
||||
<a href="{url path='admin/catalog' category_id=$ID}" title="{intl l='Browse this category'}">
|
||||
{$TITLE}
|
||||
</a>
|
||||
</td>
|
||||
<td class="object-title">
|
||||
<a href="{url path='admin/catalog' category_id=$ID}" title="{intl l='Browse this category'}">
|
||||
{$TITLE}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
{module_include location='category_list_row'}
|
||||
{module_include location='category_list_row'}
|
||||
|
||||
<td>
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"}
|
||||
<div class="make-switch switch-small categoryVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" class="categoryVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||
</div>
|
||||
{/loop}
|
||||
<td>
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"}
|
||||
<div class="make-switch switch-small categoryVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" class="categoryVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="can_change"}
|
||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||
</div>
|
||||
{/elseloop}
|
||||
</td>
|
||||
{elseloop rel="can_change"}
|
||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||
</div>
|
||||
{/elseloop}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{admin_position_block
|
||||
permission="admin.categories.edit"
|
||||
path={url path='admin/categories/update-position' category_id=$ID}
|
||||
url_parameter="category_id"
|
||||
in_place_edit_class="categoryPositionChange"
|
||||
position=$POSITION
|
||||
id=$ID
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{admin_position_block
|
||||
permission="admin.categories.edit"
|
||||
path={url path='admin/categories/update-position' category_id=$ID}
|
||||
url_parameter="category_id"
|
||||
in_place_edit_class="categoryPositionChange"
|
||||
position=$POSITION
|
||||
id=$ID
|
||||
}
|
||||
</td>
|
||||
|
||||
<td class="actions">
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Browse this category'}" href="{url path='admin/categories' category_id=$ID}"><i class="glyphicon glyphicon-folder-open"></i></a>
|
||||
<td class="actions">
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Browse this category'}" href="{url path='admin/categories' category_id=$ID}"><i class="glyphicon glyphicon-folder-open"></i></a>
|
||||
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"}
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Edit this category'}" href="{url path='/admin/categories/update' category_id=$ID}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"}
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Edit this category'}" href="{url path='/admin/categories/update' category_id=$ID}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"}
|
||||
<a class="btn btn-default btn-xs category-delete" title="{intl l='Delete this category and all its contents'}" href="#category_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
{/ifloop}
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"}
|
||||
<a class="btn btn-default btn-xs category-delete" title="{intl l='Delete this category and all its contents'}" href="#category_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
{/ifloop}
|
||||
|
||||
{elseloop rel="category_list"}
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="message">
|
||||
<div class="alert alert-info">
|
||||
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"}
|
||||
{intl l="This category has no sub-categories. To create a new one, click the + button above."}
|
||||
{/loop}
|
||||
{elseloop rel="category_list"}
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="message">
|
||||
<div class="alert alert-info">
|
||||
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"}
|
||||
{intl l="This category has no sub-categories. To create a new one, click the + button above."}
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="can_create"}
|
||||
{intl l="This category has no sub-categories."}
|
||||
{/elseloop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
{/elseloop}
|
||||
</table>
|
||||
</div>
|
||||
{elseloop rel="can_create"}
|
||||
{intl l="This category has no sub-categories."}
|
||||
{/elseloop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
{/elseloop}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{* -- PRODUCT MANAGEMENT ---------------------------------------------------- *}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="general-block-decorator">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="general-block-decorator">
|
||||
|
||||
<table class="table table-striped table-condensed">
|
||||
<caption>
|
||||
{* display parent category name *}
|
||||
{loop name="category_title" type="category" visible="*" id=$category_id}
|
||||
{intl l="Products in %cat" cat=$TITLE}
|
||||
{/loop}
|
||||
<table class="table table-striped table-condensed">
|
||||
<caption>
|
||||
{* display parent category name *}
|
||||
{loop name="category_title" type="category" visible="*" id=$category_id}
|
||||
{intl l="Products in %cat" cat=$TITLE}
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="category_title"}
|
||||
{intl l="Top level Products"}
|
||||
{/elseloop}
|
||||
{elseloop rel="category_title"}
|
||||
{intl l="Top level Products"}
|
||||
{/elseloop}
|
||||
|
||||
{module_include location='product_list_caption'}
|
||||
{module_include location='product_list_caption'}
|
||||
|
||||
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new product'}" href="#productAddModal" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
</caption>
|
||||
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new product'}" href="#product_creation_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
</caption>
|
||||
|
||||
{ifloop rel="product_list"}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='id'
|
||||
reverse_order='id_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='ID'}"
|
||||
}
|
||||
{ifloop rel="product_list"}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='id'
|
||||
reverse_order='id_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='ID'}"
|
||||
}
|
||||
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='ref'
|
||||
reverse_order='ref_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='Reference'}"
|
||||
}
|
||||
</th>
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='ref'
|
||||
reverse_order='ref_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='Reference'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='alpha'
|
||||
reverse_order='alpha_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='Product title'}"
|
||||
}
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='alpha'
|
||||
reverse_order='alpha_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='Product title'}"
|
||||
}
|
||||
|
||||
{module_include location='product_list_header'}
|
||||
{module_include location='product_list_header'}
|
||||
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='visible'
|
||||
reverse_order='visible_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='Online'}"
|
||||
}
|
||||
</th>
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='visible'
|
||||
reverse_order='visible_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='Online'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='manual'
|
||||
reverse_order='manual_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='Position'}"
|
||||
}
|
||||
</th>
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='manual'
|
||||
reverse_order='manual_reverse'
|
||||
path={url path='/admin/categories' id_category=$category_id target='products'}
|
||||
label="{intl l='Position'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{loop name="product_list" type="product" visible="*" category_default=$category_id order=$product_order}
|
||||
<tr>
|
||||
<td>{$ID}</td>
|
||||
<tbody>
|
||||
{loop name="product_list" type="product" visible="*" category_default=$category_id order=$product_order}
|
||||
<tr>
|
||||
<td>{$ID}</td>
|
||||
|
||||
<td>
|
||||
{loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
|
||||
<a href="{url path='admin/product/edit' id=$ID}" title="{intl l='Edit this product'}">
|
||||
<img src="{$IMAGE_URL}" alt="{$TITLE}" />
|
||||
</a>
|
||||
{/loop}
|
||||
<td>
|
||||
{loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
|
||||
<a href="{url path='admin/product/edit' id=$ID}" title="{intl l='Edit this product'}">
|
||||
<img src="{$IMAGE_URL}" alt="{$TITLE}" />
|
||||
</a>
|
||||
{/loop}
|
||||
|
||||
<td class="object-title"><a href="{url path="/admin/product/update/$ID"}" title="{intl l='Edit this product'}">{$REF}</a></td>
|
||||
<td class="object-title"><a href="{url path="/admin/product/update/$ID"}" title="{intl l='Edit this product'}">{$REF}</a></td>
|
||||
|
||||
<td class="object-title"><a href="{url path="/admin/product/update/$ID"}" title="{intl l='Edit this product'}">{$TITLE}</a></td>
|
||||
<td class="object-title"><a href="{url path="/admin/product/update/$ID"}" title="{intl l='Edit this product'}">{$TITLE}</a></td>
|
||||
|
||||
{module_include location='product_list_row'}
|
||||
{module_include location='product_list_row'}
|
||||
|
||||
<td>
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
|
||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" data-id="{$ID}" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||
</div>
|
||||
{/loop}
|
||||
<td>
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
|
||||
<div class="make-switch switch-small productVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="can_delete"}
|
||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" data-id="{$ID}" class="displayToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||
</div>
|
||||
{/elseloop}
|
||||
</td>
|
||||
{elseloop rel="can_change"}
|
||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||
</div>
|
||||
{/elseloop}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{admin_position_block
|
||||
permission="admin.product.edit"
|
||||
path={url path='admin/product' category_id=$ID}
|
||||
url_parameter="product_id"
|
||||
in_place_edit_class="productPositionChange"
|
||||
position=$POSITION
|
||||
id=$ID
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{admin_position_block
|
||||
permission="admin.product.edit"
|
||||
path={url path='/admin/products/update-position' product_id=$ID}
|
||||
url_parameter="product_id"
|
||||
in_place_edit_class="productPositionChange"
|
||||
position=$POSITION
|
||||
id=$ID
|
||||
}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"}
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Edit this product'}" href="{url path="admin/product/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"}
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Edit this product'}" href="{url path="admin/product/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.delete"}
|
||||
<a class="btn btn-default btn-xs product-delete" title="{intl l='Delete this product'}" href="#product_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
{/ifloop}
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.delete"}
|
||||
<a class="btn btn-default btn-xs product-delete" title="{intl l='Delete this product'}" href="#product_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
{/ifloop}
|
||||
|
||||
{elseloop rel="product_list"}
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="message"><div class="alert alert-info">{intl l="This category doesn't contains any products. To add a new product, <strong>click the + button</strong> above."}</div></td>
|
||||
</tr>
|
||||
</thead>
|
||||
{/elseloop}
|
||||
</table>
|
||||
{elseloop rel="product_list"}
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="message"><div class="alert alert-info">{intl l="This category doesn't contains any products. To add a new product, <strong>click the + button</strong> above."}</div></td>
|
||||
</tr>
|
||||
</thead>
|
||||
{/elseloop}
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{module_include location='categories_bottom'}
|
||||
|
||||
</div>
|
||||
|
||||
{module_include location='catalog_bottom'}
|
||||
</div>
|
||||
{module_include location='categories_bottom'}
|
||||
|
||||
</div>
|
||||
|
||||
{module_include location='catalog_bottom'}
|
||||
</div>
|
||||
|
||||
{* Adding a new category *}
|
||||
|
||||
{form name="thelia.admin.category.creation"}
|
||||
{* -- Adding a new category ------------------------------------------------- *}
|
||||
|
||||
{* Capture the dialog body, to pass it to the generic dialog *}
|
||||
{capture "category_creation_dialog"}
|
||||
{form name="thelia.admin.category.creation"}
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
{* Capture the dialog body, to pass it to the generic dialog *}
|
||||
{capture "category_creation_dialog"}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/categories/update' category_id='_ID_'}" />
|
||||
{/form_field}
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='parent'}
|
||||
<input type="hidden" name="{$name}" value="{$category_id}" />
|
||||
{/form_field}
|
||||
{form_field form=$form field='success_url'}
|
||||
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/categories/update' category_id='_ID_'}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
<div class="input-group">
|
||||
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency name'}" placeholder="{intl l='Name'}">
|
||||
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="$TITLE" /></span>
|
||||
</div>
|
||||
{form_field form=$form field='parent'}
|
||||
<input type="hidden" name="{$name}" value="{$category_id}" />
|
||||
{/form_field}
|
||||
|
||||
<div class="help-block">{intl l='Enter here the category name in the default language (%title)' title="$TITLE"}</div>
|
||||
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$LOCALE}" />
|
||||
{/form_field}
|
||||
{/loop}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='visible'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" checked="checked">
|
||||
{$label}
|
||||
</label>
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
<div class="input-group">
|
||||
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Category title'}" placeholder="{intl l='Name'}">
|
||||
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="$TITLE" /></span>
|
||||
</div>
|
||||
|
||||
<div class="help-block">{intl l='Enter here the category name in the default language (%title)' title="$TITLE"}</div>
|
||||
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$LOCALE}" />
|
||||
{/form_field}
|
||||
{/loop}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='visible'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" checked="checked">
|
||||
{$label}
|
||||
</label>
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{module_include location='category_create_form'}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-create-dialog.html"
|
||||
|
||||
dialog_id = "category_creation_dialog"
|
||||
dialog_title = {intl l="Create a new category"}
|
||||
dialog_body = {$smarty.capture.category_creation_dialog nofilter}
|
||||
|
||||
dialog_ok_label = {intl l="Create this category"}
|
||||
|
||||
form_action = {url path='/admin/categories/create'}
|
||||
form_enctype = {form_enctype form=$form}
|
||||
form_error_message = $form_error_message
|
||||
}
|
||||
{/form}
|
||||
|
||||
|
||||
{* Delete category confirmation dialog *}
|
||||
|
||||
{capture "category_delete_dialog"}
|
||||
<input type="hidden" name="category_id" id="category_delete_id" value="" />
|
||||
|
||||
{module_include location='category_delete_form'}
|
||||
{module_include location='category_create_form'}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-confirm-dialog.html"
|
||||
file = "includes/generic-create-dialog.html"
|
||||
|
||||
dialog_id = "category_delete_dialog"
|
||||
dialog_title = {intl l="Delete category"}
|
||||
dialog_message = {intl l="Do you really want to delete this category and all its content ?"}
|
||||
dialog_id = "category_creation_dialog"
|
||||
dialog_title = {intl l="Create a new category"}
|
||||
dialog_body = {$smarty.capture.category_creation_dialog nofilter}
|
||||
|
||||
form_action = {url path='/admin/categories/delete'}
|
||||
form_content = {$smarty.capture.category_delete_dialog nofilter}
|
||||
dialog_ok_label = {intl l="Create this category"}
|
||||
|
||||
form_action = {url path='/admin/categories/create'}
|
||||
form_enctype = {form_enctype form=$form}
|
||||
form_error_message = $form_error_message
|
||||
}
|
||||
{/form}
|
||||
|
||||
{* Delete product confirmation dialog *}
|
||||
{* -- Adding a new product -------------------------------------------------- *}
|
||||
|
||||
{capture "product_delete_dialog"}
|
||||
<input type="hidden" name="product_id" id="product_delete_id" value="" />
|
||||
{form name="thelia.admin.product.creation"}
|
||||
|
||||
{module_include location='product_delete_form'}
|
||||
{* Capture the dialog body, to pass it to the generic dialog *}
|
||||
{capture "product_creation_dialog"}
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{* Be sure to get the category_id, even if the form could not be validated *}
|
||||
<input type="hidden" name="category_id" value="{$category_id}" />
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/products/update' product_id='_ID_'}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='default_category'}
|
||||
<input type="hidden" name="{$name}" value="{$category_id}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='ref'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
|
||||
<div class="from-group">
|
||||
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Reference'}">
|
||||
</div>
|
||||
|
||||
<div class="help-block">{intl l='Enter here the product reference'}</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
<div class="input-group">
|
||||
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Title'}">
|
||||
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="$TITLE" /></span>
|
||||
</div>
|
||||
|
||||
<div class="help-block">{intl l='Enter here the product name in the default language (%title)' title="$TITLE"}</div>
|
||||
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$LOCALE}" />
|
||||
{/form_field}
|
||||
{/loop}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='visible'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" checked="checked">
|
||||
{$label}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{module_include location='product_create_form'}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-confirm-dialog.html"
|
||||
file = "includes/generic-create-dialog.html"
|
||||
|
||||
dialog_id = "product_delete_dialog"
|
||||
dialog_title = {intl l="Delete product"}
|
||||
dialog_message = {intl l="Do you really want to delete this product ?"}
|
||||
dialog_id = "product_creation_dialog"
|
||||
dialog_title = {intl l="Create a new product"}
|
||||
dialog_body = {$smarty.capture.product_creation_dialog nofilter}
|
||||
|
||||
form_action = {url path='/admin/products/delete'}
|
||||
form_content = {$smarty.capture.product_delete_dialog nofilter}
|
||||
dialog_ok_label = {intl l="Create this product"}
|
||||
|
||||
form_action = {url path='/admin/products/create'}
|
||||
form_enctype = {form_enctype form=$form}
|
||||
form_error_message = $form_error_message
|
||||
}
|
||||
{/form}
|
||||
|
||||
{* -- Delete category confirmation dialog ----------------------------------- *}
|
||||
|
||||
{capture "category_delete_dialog"}
|
||||
<input type="hidden" name="category_id" id="category_delete_id" value="" />
|
||||
|
||||
{module_include location='category_delete_form'}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-confirm-dialog.html"
|
||||
|
||||
dialog_id = "category_delete_dialog"
|
||||
dialog_title = {intl l="Delete category"}
|
||||
dialog_message = {intl l="Do you really want to delete this category and all its content ?"}
|
||||
|
||||
form_action = {url path='/admin/categories/delete'}
|
||||
form_content = {$smarty.capture.category_delete_dialog nofilter}
|
||||
}
|
||||
|
||||
{* -- Delete product confirmation dialog ------------------------------------ *}
|
||||
|
||||
{capture "product_delete_dialog"}
|
||||
<input type="hidden" name="product_id" id="product_delete_id" value="" />
|
||||
<input type="hidden" name="category_id" value="{$category_id}" />
|
||||
|
||||
{module_include location='product_delete_form'}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-confirm-dialog.html"
|
||||
|
||||
dialog_id = "product_delete_dialog"
|
||||
dialog_title = {intl l="Delete product"}
|
||||
dialog_message = {intl l="Do you really want to delete this product ?"}
|
||||
|
||||
form_action = {url path='/admin/products/delete'}
|
||||
form_content = {$smarty.capture.product_delete_dialog nofilter}
|
||||
}
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
@@ -483,11 +565,15 @@
|
||||
form_name = "thelia.admin.category.creation"
|
||||
}
|
||||
|
||||
{include
|
||||
file = "includes/generic-js-dialog.html"
|
||||
dialog_id = "product_creation_dialog"
|
||||
form_name = "thelia.admin.product.creation"
|
||||
}
|
||||
|
||||
{* Toggle object visibility *}
|
||||
|
||||
|
||||
$(".categoryVisibleToggle").on('switch-change', function(event, data) {
|
||||
console.log("yaya");
|
||||
$.ajax({
|
||||
url : "{url path='admin/categories/toggle-online'}",
|
||||
data : {
|
||||
@@ -497,6 +583,17 @@
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(".productVisibleToggle").on('switch-change', function(event, data) {
|
||||
$.ajax({
|
||||
url : "{url path='admin/products/toggle-online'}",
|
||||
data : {
|
||||
product_id : $(this).data('id'),
|
||||
action : 'visibilityToggle'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
{* Inline editing of object position using bootstrap-editable *}
|
||||
|
||||
$('.categoryPositionChange').editable({
|
||||
@@ -518,6 +615,25 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('.productPositionChange').editable({
|
||||
type : 'text',
|
||||
title : '{intl l="Enter new product position"}',
|
||||
mode : 'popup',
|
||||
inputclass : 'input-mini',
|
||||
placement : 'left',
|
||||
success : function(response, newValue) {
|
||||
// The URL template
|
||||
var url = "{url path='/admin/products/update-position' product_id='__ID__' position='__POS__'}";
|
||||
|
||||
// Perform subtitutions
|
||||
url = url.replace('__ID__', $(this).data('id'))
|
||||
.replace('__POS__', newValue);
|
||||
|
||||
// Reload the page
|
||||
location.href = url;
|
||||
}
|
||||
});
|
||||
|
||||
{* Change default status *}
|
||||
|
||||
$('.change-default').change(function(ev) {
|
||||
|
||||
Reference in New Issue
Block a user